package com.test.view;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class MainFrm extends javax.swing.JFrame {

    //GEN-BEGIN:variables
    // Variables declaration - do not modify
    private javax.swing.JMenu jMlocalMessage;
    private javax.swing.JMenu jMstudentManageTop;
    private javax.swing.JMenu jMcourseManageTop;
    private javax.swing.JMenu jMtestcoresManageTop;
    private javax.swing.JMenuBar jMBTop;
    private javax.swing.JMenuItem jmiCourseManage;
    private javax.swing.JMenuItem jmistudent;
    private javax.swing.JMenuItem jmiTestScores;
    private javax.swing.JMenuItem jmiExit;
    private javax.swing.JDesktopPane table;

    /** Creates new form MainFrm */
    public MainFrm() {
        initComponents();
        // 设置最大化
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    }


    //GEN-BEGIN:initComponents
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        table = new javax.swing.JDesktopPane();
        jMBTop = new javax.swing.JMenuBar();
        jMlocalMessage = new javax.swing.JMenu();

        jMstudentManageTop = new javax.swing.JMenu();
        jmistudent = new javax.swing.JMenuItem();

        jMcourseManageTop = new javax.swing.JMenu();
        jmiCourseManage = new javax.swing.JMenuItem();

        jMtestcoresManageTop = new javax.swing.JMenu();
        jmiTestScores = new javax.swing.JMenuItem();

        jmiExit = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("管理员界面");

        jMstudentManageTop.setIcon(new javax.swing.ImageIcon(
                "C:\\Users\\caofeng\\Desktop\\images\\bookTypeManager.png")); // NOI18N
        jMstudentManageTop.setText("学生管理");

        jmistudent.setIcon(new javax.swing.ImageIcon(
                "C:\\Users\\caofeng\\Desktop\\images\\add.png")); // NOI18N
        jmistudent.setText("学生管理01");
        jmistudent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiStudentManageActionPerformed(evt);
            }
        });
        jMstudentManageTop.add(jmistudent);


        jMBTop.add(jMstudentManageTop);

        jMcourseManageTop.setIcon(new javax.swing.ImageIcon(
                "C:\\Users\\caofeng\\Desktop\\images\\bookManager.png")); // NOI18N
        jMcourseManageTop.setText("课程管理");

        jmiCourseManage.setIcon(new javax.swing.ImageIcon(
                "C:\\Users\\caofeng\\Desktop\\images\\add.png")); // NOI18N
        jmiCourseManage.setText("管理课程001");
        jMcourseManageTop.add(jmiCourseManage);
        jmiCourseManage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiCourseManageActionPerformed(evt);
            }
        });

        jMBTop.add(jMcourseManageTop);

        //成绩管理
        jMtestcoresManageTop.setText("成绩管理");
        jmiTestScores.setText("成绩管理01");
        jMtestcoresManageTop.add(jmiTestScores);
        jmiTestScores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiTestScoresManage(evt);
            }
        });

        jMBTop.add(jMtestcoresManageTop);


        //退出
        jmiExit.setIcon(new javax.swing.ImageIcon(
                "C:\\Users\\caofeng\\Desktop\\images\\exit.png")); // NOI18N
        jmiExit.setText("退出系統");
        jmiExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiExitActionPerformed(evt);
            }
        });

        jMBTop.add(jmiExit);



        setJMenuBar(jMBTop);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
                getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addComponent(table,
                javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addComponent(table,
                javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE));

        pack();
    }

    private void jmiStudentManageActionPerformed(java.awt.event.ActionEvent evt) {

        StudentView stuView = new StudentView();

        stuView.setVisible(true);
        this.table.add(stuView);

    }

    private void jmiCourseManageActionPerformed(java.awt.event.ActionEvent evt) {
        CourseView stuView = new CourseView();

        stuView.setVisible(true);
        this.table.add(stuView);
    }


    private void jmiTestScoresManage(java.awt.event.ActionEvent evt) {
        TestScoresView stuView = new TestScoresView();

        stuView.setVisible(true);
        this.table.add(stuView);
    }

    private void jmiExitActionPerformed(java.awt.event.ActionEvent evt) {
        int result = JOptionPane.showConfirmDialog(null, "是否退出系统");
        if (result == 0) {
            this.dispose();
        }
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainFrm().setVisible(true);
            }
        });
    }



}
